package com.woniu.p2p.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.p2p.entity.User;
import com.woniu.p2p.entity.UserZong;
import com.woniu.p2p.mapper.UserInvestMapper;
import com.woniu.p2p.mapper.UserMapper;
import com.woniu.p2p.mapper.UserZongMapper;
import com.woniu.p2p.service.UserInfoSevice;
import com.woniu.p2p.vo.UserInfoVo;
import com.woniu.p2p.vo.UserInvestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * UserInfoImpl
 *
 * @author 郭耀文
 * @date 2020/8/8
 */
@Service
public class UserInfoSeviceImpl implements UserInfoSevice {

    @Autowired
    UserMapper userMapper;

    @Autowired
    UserZongMapper userZongMapper;

    @Autowired
    UserInvestMapper userInvestMapper;



    @Override
    public UserInfoVo findByUserId(Integer id) {
        return userMapper.findUserInfo(id);
    }

    @Override
    public int selectloansDoce(Integer id) {
        return userMapper.selectloansDoce(id);
    }

    @Override
    public BigDecimal selectLonasMoney(Integer id) {
        return userMapper.selectLonasMoney(id);
    }

    @Override
    public int selectUserInvest(Integer id) {
        return userMapper.selectUserInvest(id);
    }

    @Override
    public BigDecimal selectUserPayMoney(Integer id) {
        return userMapper.selectUserPayMoney(id);
    }

    @Override
    public PageInfo<UserZong> seletAllUserZong(Integer id, Integer start, Integer num) {
        PageHelper.startPage(start,num);
        List<UserZong> userZongs = userZongMapper.selectByUserId(id);

        PageInfo<UserZong> pageUserZong=new PageInfo<>(userZongs);

        return pageUserZong;
    }

    @Override
    public PageInfo<UserInvestVo> selectAllUserInvestVo(Integer id, Integer start, Integer num) {
        PageHelper.startPage(start,num);
        List<UserInvestVo> userInvestVos = userInvestMapper.selectAllUserInvest(id);
        PageInfo<UserInvestVo> pageInfo=new PageInfo<>(userInvestVos);
        return pageInfo;
    }


    @Override
    public User findUserInfoById(Integer uid) {
        return userMapper.selectByPrimaryKey(uid);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateByPrimaryKey(user);
    }
}
